package com.example.service.impl;

import com.example.entity.Article;
import com.example.repository.ArticleRepository;
import com.example.service.ArticleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService{

    @Resource
    private ArticleRepository articleRepository;


    @Override
    public PageInfo<Article> findAll(int page, int size) {

        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(page,size);

        List<Article> all = articleRepository.findAll();

        PageInfo<Article> articlePageInfo = new PageInfo<>(all);

        return articlePageInfo;
    }

    @Override
    public List<Article> findCommentByArticle(int id) {
        List<Article> commentByArticle = articleRepository.findCommentByArticle(id);
        return commentByArticle;
    }


}
